define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index:function () {
            var temple_id = Config.temple_id;
            Table.api.init({
                extend: {
                    index_url: 'usernote/index/ids/'+temple_id
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                searchFormVisible:true,
                columns: [
                    [
                        {field: 'state', checkbox: true },
                        {field: 'user.nickname', title: __('Nickname')},
                        {field: 'temple_name', title: __('Temple name'),operate:false,searchable:false},
                        {field: 'note.name', title: __('Name')},
                        {field: 'note.desc', title: __('Desc')},
                        {field: 'is_solve', title: __('Is solve'), sortable:true,
                            searchList: {"0": __('No'), "1": __('Yes')},
                            formatter:function(value,row,index){
                                switch (value){
                                    case 0:
                                        return __('No');
                                    case 1:
                                        return __('Yes');
                                    default:
                                        return __('No');
                                }
                            } },
                        {field: 'solve_note_text', title: __('Solve note'), operate:false, formatter: Table.api.formatter.label},
                        {field: 'content_text', title: __('Content'), operate:false, formatter: Table.api.formatter.label},
                        {field: 'create_time', title: __('Create time'),
                            formatter: Table.api.formatter.datetime, operate: 'BETWEEN',
                            type: 'datetime', addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});